package SV_UMC_JDBC;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Example {
    protected void doPost(HttpServletRequest req,
                          HttpServletResponse resp) throws ServletException {
        String name = req.getParameter("userName");
        String pswd = req.getParameter("passwd");
        Connection conn = doGetConnection(name, pswd);
        // ...
    }
    private Connection doGetConnection(String name,
                                       String pswd) {
        Connection conn = null;
        try {
            return DriverManager.getConnection("localhost:3300",
                    name, pswd);
        } catch (SQLException e) {
            // ...
        }
        return conn;
    }
}
